<template>
    <view :class="uiStyle == 1 ? '' : 'uiStyle'">
        <!-- pages/order/index.wxml -->
		<view class="head-block" v-if="weixin == 2">
				     <view class="nav-title" :style="'top:10px'"></view>
					 <!-- 返回 -->
					 <view class="icons" @tap="goMy" :style="'top:6px'">
					      <van-icon name="arrow-left" color="#333" size="45rpx" />
					  </view>
				 </view>
        <topBar text="发布车位" :needBack="true"></topBar>
        <view class="order" :style="weixin == 2 ? 'top:60rpx' : 'top:30rpx'">
            <view v-if="banner.length > 0" class="banneritem">
                <view class="swiper" :data-parkingNumber="item.parkingNumber" v-for="(item, index) in banner" :key="item.id">
                    <view class="banner-swiper" v-if="item.authStatus == 1">
                        <image class="swiperBg" src="../../static/assets/img/card-lv-hover.png" mode="widthFix"></image>
                        <view class="banner-body">
                            <view class="price">
                                <view class="num">
                                    {{ item.actualPay / 100 }}
                                    <text class="yuan">元</text>
                                </view>
                                <view class="word">已赚</view>
                            </view>
                            <view class="detail-text" @tap="goBill" :data-data="item">查看明细</view>
                            <view class="icon">
                                <view v-if="item.orderStatus === 1 || item.orderStatus === 7">
                                    <image src="../../static/assets/img/icon1.png" style="width: 120rpx" mode="widthFix" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                                <view v-if="item.orderStatus === 2 || item.orderStatus === 4 || item.orderStatus === 5">
                                    <image src="../../static/assets/img/icon4.png" mode="widthFix" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                                <view v-if="item.orderStatus === 6">
                                    <image src="/static/assets/img/icon5.png" mode="widthFix" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                                <view v-if="item.orderStatus === 3">
                                    <image src="../../static/assets/img/icon2.png" mode="widthFix" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                            </view>
                            <view class="card-order-l-t new-blt">
                                <view class="card-order-spnum">
                                    <view class="spnum-fixtext">车位</view>
                                    <view class="spnum-num">{{ item.parkingNumber }}</view>
                                </view>
                                <view class="release-box">
                                    <text class="release-text" v-if="item.saleStatus == 0" :decode="true">已下架&nbsp;&nbsp;</text>
                                    <text class="release-text" v-else :decode="true">已上架&nbsp;&nbsp;</text>
                                    <van-switch size="18px"  v-model="item.saleStatus == 1" @change="handlechangeSaleStatus($event, { value: item })" :data-value="item" />
                                    <!-- <text class="banner-f-text" wx:if="{{item.saleStatus==0}}" data-value="{{item}}" catchtap="handlechangeSaleStatus">上架</text>
                <text class="banner-f-text" wx:if="{{item.saleStatus==1}}" data-value="{{item}}" catchtap="handlechangeSaleStatus">下架</text> -->
                                </view>
                            </view>
                            <view class="card-order-spname">{{ item.parkingName }}</view>
                            <view class="statu" style="display: flex; margin-bottom: 10rpx">
                                <view class="statuView" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.haveCharge">
                                    <image mode="widthFix" class="img-tag" src="../../static/assets/img/elc.png" />
                                    <view>有充电桩</view>
                                </view>
                                <view class="statuView" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.spaceType == 2">
                                    <image mode="widthFix" class="img-tag" src="../../static/assets/img/under.png" />
                                    <view>地下</view>
                                </view>
                                <view class="statuView" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.spaceType == 1">
                                    <image mode="widthFix" class="img-tag" src="../../static/assets/img/ground.png" />
                                    <view>地面</view>
                                </view>
                                <view class="statuView" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.spaceType == 3">
                                    <image mode="widthFix" class="img-tag" src="../../static/assets/img/3dpark.png" />
                                    <view>立体车库</view>
                                </view>
                            </view>
                            <van-rate readonly v-model="item.evaluate" color="#ffd21e" void-icon="star" void-color="#eee" :size="15" style="margin-left: -20rpx" />

                            <view class="card-order-l-c">
                                <view class="card-order-l-text" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.isTemp == 1">
                                    共享方式：
                                    <text style="color: #000">临停</text>
                                </view>
                                <view class="card-order-l-text" v-else-if="!item.plmParkingSpaceManage && !item.plmParkingSpaceManage.isTemp">共享方式：</view>
                                <view class="card-order-l-text" v-else>
                                    共享方式：
                                    <text style="color: #000">包月</text>
                                </view>
                                <view class="card-order-l-text" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.isTemp == 1">
                                    <text :decode="true">
                                        &nbsp;&nbsp;&nbsp;&nbsp;重复周期：
                                        <text style="color: #000">{{ item.addCycleName }}</text>
                                    </text>
                                </view>
                            </view>
                            <view class="card-order-l-c">
                                <view class="card-order-l-content" v-if="item.plmParkingSpaceManage&&item.plmParkingSpaceManage.isTemp == 1">
                                    <view style="color: #000">
                                        {{ item.plmParkingSpaceManage.validStartTime || '--' }}~{{ item.plmParkingSpaceManage.validEndTime || '--' }}
                                        {{ item.plmParkingSpaceManage.tempStartTime || '--' }}~{{ item.plmParkingSpaceManage.tempEndTime || '--' }}
                                    </view>
                                </view>
                                <view class="card-order-l-content" v-else>
                                    <view style="color: #000">{{ item.plmParkingSpaceManage.validStartTime || '--' }}~{{ item.plmParkingSpaceManage.validEndTime || '--' }}</view>
                                </view>
                                <view class="banner-f-2" :data-value="item" @tap="handleedit">
                                    <image src="../../static/assets/img/communitybj.png" alt=""></image>
                                    <view class="banner-f-text">编辑</view>
                                </view>
                            </view>
                            <!-- <view class="card-order-l-c">
                        <view class="card-order-l-text">共享时段：</view>
                        <view class="card-order-l-content">
                            <view wx:if="{{item.plmParkingSpaceManage.isTemp==1}}">{{item.plmParkingSpaceManage.tempStartTime || '--'}}~{{item.plmParkingSpaceManage.tempEndTime || '--'}}</view>
                            <view wx:else>全天（默认）</view>
                        </view>
                    </view> -->
                            <!-- <view class="card-order-l-c" wx:if="{{item.plmParkingSpaceManage.isTemp==1}}">
                        <view class="card-order-l-text">
                            <text decode="true">循&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;环：</text>
                        </view>
                        <view class="card-order-l-content">
                            <view>{{item.addCycleName || '--'}}</view>
                        </view>
                    </view> -->
                        </view>
                        <view class="banner-footer"></view>
                    </view>

                    <view class="banner-swiper" v-else>
                        <image class="swiperBg" src="../../static/assets/img/card-lv-hover.png" style="height: 200rpx"></image>
                        <view class="banner-body">
                            <view class="icon">
                                <view v-if="item.orderStatus === 1 || item.orderStatus === 7">
                                    <image src="../../static/assets/img/icon1.png" style="width: 120rpx" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                                <view v-if="item.orderStatus === 2 || item.orderStatus === 4 || item.orderStatus === 5">
                                    <image src="../../static/assets/img/icon4.png" mode="widthFix" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                                <view v-if="item.orderStatus === 6">
                                    <image src="/static/assets/img/icon5.png" mode="widthFix" />
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                                <view v-if="item.orderStatus === 3">
                                    <image src="../../static/assets/img/icon2.png"  mode="widthFix"/>
                                    <view class="icon-text">{{ item.type }}</view>
                                </view>
                            </view>
                            <view class="card-order-l-t">
                                <view class="card-order-spnum" style="margin: 35rpx 0 10rpx 0">
                                    <view class="spnum-fixtext">车位</view>
                                    <view class="spnum-num">{{ item.parkingNumber }}</view>
                                </view>
                                <!-- 认证状态 0:待审核, 1审核通过, -1审核不通过 -->
                                <view v-if="item.authStatus == 0" class="statuView2" style="margin: 28rpx 0">
                                    <view class="statu statuName" style="color: #ffa000">审核中</view>
                                </view>
                                <view v-if="item.authStatus == 1" class="statuView2" style="margin: 28rpx 0">
                                    <view class="statu statuName">审核通过</view>
                                    <view class="statu statuImg" :data-value="item" @tap="handleedit">
                                        <image src="../../static/assets/img/public.png" mode="widthFix" />
                                        发布
                                    </view>
                                </view>
                                <view v-if="item.authStatus == -1" class="statuView2" style="margin: 28rpx 0">
                                    <view class="statu statuName" style="color: #fb6b61">审核未通过</view>
                                    <view class="statu statuImg" @tap="gotoAdd">
                                        <image src="../../static/assets/img/resubmit.png" mode="widthFix" />
                                        重新提交
                                    </view>
                                </view>
                                <view class="card-order-spname">{{ item.parkingName }}</view>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
            <view class="no-data" v-else style="margin-top: 200rpx">
                <image style="display: block; margin: 0 auto" src="../../static/assets/img/No-Data2.png" mode="widthFix"></image>
                <view class="no-data-info">您名下暂无车位，请点击下方“添加车位”， 审核通过后就能发布啦！</view>
            </view>
            <view class="fix-btm" v-if="!projectId">
				
                <view class="btn" @tap="gotoAdd">+ 添加车位</view>
                <!-- <view class="tip-text">提示：*******</view> -->
            </view>
            <!-- 信息提示弹窗 -->
            <van-dialog
                use-slot
                title="信息留言"
                v-model="textShow"
                round-button
                show-cancel-button
                confirm-button-open-type="getUserInfo"
                @close="ontextClose"
                @getuserinfo="getUserInfo"
                class="popup"
                confirm-button-color="#00BCAB"
            >
                <van-cell-group>
                    <van-field v-model="message" label="留言" type="textarea" placeholder="请输入留言" autosize :border="false" />
                </van-cell-group>
            </van-dialog>
            <!-- 评价弹出框 -->
            <van-dialog
                use-slot
                title="请为车主评分"
                v-model="Valuateshow"
                show-cancel-button
                confirm-button-open-type="getUserInfo"
                @close="onCloseValuate"
                @confirm="getUserInfoValuate"
                class="popup"
                confirm-button-color="#00BCAB"
            >
                <van-rate readonly v-model="valueRate" :size="25" color="#FF9800;" void-color="#eee" void-icon="star" @change="onChangeValueRate" />
                <van-field v-model="Valuatemessage" label="留言" type="textarea" placeholder="请输入留言" autosize :border="false" @change="changeValuatemessage" />
            </van-dialog>
            <!-- 取消预约 -->
            <van-dialog id="van-dialog" confirm-button-color="#00BCAB" />
            <!-- 拒绝退租弹窗 -->
            <van-dialog id="van-dialog" />
        </view>
    </view>
</template>

<script>
import util from './../../utils/util.js';
import api from './../../utils/api.js'; // import Dialog from "@vant/weapp/dist/dialog/dialog";
import { Dialog } from 'vant';
export default {
    data() {
        return {
            autoplay: false,

            // unionId: "fb0feca5-0945-4989-b4aa-8c33413ff648",
            // unionId: wx.getStorageSync("unionId") || "",
            list: [],

            banner: [],
            value1: 0,
            valueCar: '浙AAAA',

            //显示车牌号
            show: false,

            //联系车主弹窗
            textShow: false,

            //留言
            message: '',

            //留言
            Valuatemessage: '',

            //评价留言
            Valuateshow: false,

            //评价
            valueRate: 1,

            //评分
            cancelshow: false,

            //取消预约
            showMessage: false,

            //更多操作
            personType: 2,

            //人员类型 1车位｜2车为主//我的小区查询的就是车位主
            parkingSpace: '',

            active: 0,

            //tab切换
            carOrderLogId: '',

            //订单号
            currentbanner: 0,

            phoneNumber: null,

            temp: [
                {
                    id: 40,
                    parkingNumber: 'c116',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 53,
                        state: 1,
                        createTime: '2021-10-28 14:44:19',
                        modifiedTime: '2021-10-29 20:47:54',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c116',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '02:00:00',
                        tempEndTime: '23:59:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: 1635511674000,
                        fiveColorId: null
                    }
                },
                {
                    id: 41,
                    parkingNumber: 'c119',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 54,
                        state: 1,
                        createTime: '2021-10-28 14:45:05',
                        modifiedTime: '2021-10-29 20:18:56',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c119',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '06:00',
                        tempEndTime: '23:01',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 42,
                    parkingNumber: 'c120',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 55,
                        state: 1,
                        createTime: '2021-10-28 14:45:38',
                        modifiedTime: '2021-10-29 19:34:57',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c120',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '06:00:00',
                        tempEndTime: '22:01:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 46,
                    parkingNumber: 'c127',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 56,
                        state: 1,
                        createTime: '2021-10-28 18:45:17',
                        modifiedTime: '2021-10-29 20:18:53',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c127',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '12:00:00',
                        tempEndTime: '23:01:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 49,
                    parkingNumber: 'c131',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 58,
                        state: 1,
                        createTime: '2021-10-29 10:02:29',
                        modifiedTime: '2021-10-29 20:18:34',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c131',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-29 00:00:00',
                        validEndTime: '2021-11-29 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '02:00:00',
                        tempEndTime: '23:56:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 6,
                    parkingNumber: 'a01',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                },
                {
                    id: 45,
                    parkingNumber: 'c122',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                },
                {
                    id: 47,
                    parkingNumber: 'c129',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                },
                {
                    id: 48,
                    parkingNumber: 'c130',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                }
            ],

            activeOrderId: '',
            saleStatus: 0,
			uiStyle:1,
			weixin:uni.getStorageSync('weixin'),
			projectId:uni.getStorageSync('projectId') || ''
        };
    },
    onLoad: function (options) {
		this.uiStyle = uni.getStorageSync('uiStyle') || 1
        // 处理关于分享的用户unionId
        if (options.shareId && options.shareId != '') {
            uni.setStorageSync('shareId', options.shareId);
        }

        if (options.activityCode && options.activityCode != '') {
            uni.setStorageSync('activityCode', options.activityCode);
        }

        this.getmySpaceList();
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.getmySpaceList();
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    // onShareAppMessage: function() {}
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */ methods: {
        handleBanner(e) {
            this.setData({
                active: 0,
                parkingSpace: this.banner[e.detail.current].parkingNumber,
                currentbanner: e.detail.current
            });
            this.getmyCarOrderLog();
        },

        change({ detail }) {
            this.setData({
                value1: detail,
                valueCar: this.option1.find((e) => e.value === detail).text
            });
        },

        //联系车主弹窗
        showPopup(e) {
            // console.log("showPopup");
            this.setData({
                show: true,
                carOrderLogId: e.currentTarget.dataset.id
            });
        },

        goBill(e) {
            console.log(e.currentTarget.dataset.data);
            var parkingCode = e.currentTarget.dataset.data.parkingCode;
            var spaceNo = e.currentTarget.dataset.data.parkingNumber;
            uni.navigateTo({
                url: '../communityOrderDetail/index?parkingCode=' + parkingCode + '&spaceNo=' + spaceNo
            });
        },
		goMy() {
		     uni.navigateBack({
		         delta: 1
		     });
		 },
        //联系方式
        getcall() {
            const unionId = uni.getStorageSync('unionId') || '';
            util.request(api.call + '?carOrderLogId=' + this.carOrderLogId + '&userUnionId=' + unionId + '&type=1', 'get').then((res) => {
                if (res.code == 0) {
					if(uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4){
						ZWJSBridge.phoneCall({
						  "corpId": res.data
						}).then(res => {
						  console.log(res)
						}).catch(err => {
						  console.log(err) 
						})
					}else{
						uni.makePhoneCall({
							phoneNumber: res.data
						}).catch((e) => {
							console.log(e);
						});
					}
                } else {
                    uni.showToast({
                        title: res.msg,
                        icon: 'none'
                    });
                }
            });
        },

        onClose() {
            this.setData({
                show: false
            });
        },

        //弹出层电话
        handlePopphone() {
            this.getcall();
        },

        //留言
        getUserInfo(event) {
            // console.log(event.detail);
        },

        showtextPopup() {
            // console.log(this.data.textShow);
            this.setData({
                textShow: true
            });
            this.setData({
                show: false
            });
        },

        ontextClose() {
            this.setData({
                textShow: false
            });
        },

        //请评价
        handleeValuate(e) {
            this.setData({
                Valuateshow: true,
                activeOrderId: e.currentTarget.dataset.orderid
            });
        },

        onCloseValuate() {
            this.setData({
                Valuateshow: false
            });
        },

        onChangeValueRate(e) {
            this.setData({
                valueRate: e.detail
            });
        },

        changeValuatemessage(e) {
            this.setData({
                Valuatemessage: e.detail
            });
        },

        getUserInfoValuate(event) {
            const unionId = uni.getStorageSync('unionId') || '';
            const { activeOrderId, valueRate, Valuatemessage } = this;
            const param = {
                orderId: activeOrderId,
                userUnionId: unionId,
                evaluateScore: valueRate,
                evaluateContent: Valuatemessage
            };
            util.request(api.userEvaluate, param, 'post').then((res) => {
                if (res.code == 0) {
                    uni.showToast({
                        title: res.msg,
                        icon: 'success'
                    });
                } else {
                    uni.showToast({
                        title: res.msg,
                        icon: 'none'
                    });
                }

                this.setData({
                    activeOrderId: null,
                    valueRate: 1,
                    Valuatemessage: ''
                });
            });
        },

        //取消申请退租
        cancelwithdraw() {
            const unionId = uni.getStorageSync('unionId') || '';
            Dialog.confirm({
                title: '取消申请',
                message: '是否确认取消申请？'
            }).then((res) => {
                util.request(api.withdraw + `?userUnionId=${unionId}`, 'get').then((res) => {
                    if (res.code == 0) {
                        this.getmyCarOrderLog();
                        uni.showToast({
                            title: res.data,
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                });
            });
        },

        // 申请退租
        cancelApply(e) {
            const carOrderLogId = e.currentTarget.dataset.id;
            const unionId = uni.getStorageSync('unionId') || '';
            Dialog.confirm({
                title: '申请退租',
                message: '是否确认申请退租？'
            }).then((res) => {
                util.request(api.cancelApply + `?carOrderLogId=${carOrderLogId}&userUnionId=${unionId}`, 'get').then((res) => {
                    if (res.code == 0) {
                        this.getmyCarOrderLog();
                        uni.showToast({
                            title: res.data,
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                });
            });
        },

        gotoAdd() {
            const value = 2; //../communityOrder/index

            uni.navigateTo({
                url: '../applyStep1/applyStep1' //../setParking1/index?active= + value
            });
        },

        // 同意/拒绝退租
        cancelReply(e) {
            const carOrderLogId = e.currentTarget.dataset.id;
            const type = e.currentTarget.dataset.type;
            const unionId = uni.getStorageSync('unionId') || '';
            Dialog.confirm({
                title: '退租处理',
                message: `是否${type ? '同意' : '拒绝'}退租？`
            }).then((res) => {
                util.request(api.cancelReply + `?carOrderLogId=${carOrderLogId}&userUnionId=${unionId}&replyResult=${type}`, 'get').then((res) => {
                    if (res.code == 0) {
                        this.getmyCarOrderLog();
                        uni.showToast({
                            title: res.data,
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                });
            });
        },

        //取消预约弹窗
        handleCancel(e) {
            // console.log(e, "aaa");
            Dialog.confirm({
                title: '标题',
                message: '是否取消预约'
            })
                .then(() => {
                    // on confirm
                })
                .catch(() => {
                    // on cancel
                });
        },

        //我的车位
        getmySpaceList() {
            const unionId = uni.getStorageSync('unionId') || '';
            util.request(api.mySpaceList + '?userUnionId=' + unionId, 'get').then((res) => {
                if (res.code == 0) {
                    let lists = res.data; // let lists = this.data.temp

                    lists &
                        lists.map((e) => {
                            if (e.plmParkingSpaceManage != null) {
                                //包月的显示 全天（默认）
                                if (e.plmParkingSpaceManage.tempCycle == '0000000' || e.plmParkingSpaceManage.tempCycle == null) {
                                    e.addCycleName = '不重复';
                                } else if (e.plmParkingSpaceManage.tempCycle == '1111111') {
                                    e.addCycleName = '每天';
                                } else {
                                    let cy = e.plmParkingSpaceManage.tempCycle.split('');
                                    e.addCycleName = '每周';

                                    if (cy[0] == 1) {
                                        e.addCycleName += '一 ';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[1] == 1) {
                                        e.addCycleName += '二 ';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[2] == 1) {
                                        e.addCycleName += '三 ';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[3] == 1) {
                                        e.addCycleName += '四 ';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[4] == 1) {
                                        e.addCycleName += '五 ';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[5] == 1) {
                                        e.addCycleName += '六 ';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[6] == 1) {
                                        e.addCycleName += '日';
                                    } else {
                                        e.addCycleName += '';
                                    }
                                }

                                e.plmParkingSpaceManage.validStartTime = e.plmParkingSpaceManage.validStartTime.toString().split(' ')[0] || '';
                                e.plmParkingSpaceManage.validEndTime = e.plmParkingSpaceManage.validEndTime.toString().split(' ')[0] || '';
                            }else{
								e.plmParkingSpaceManage={}
							}
                        }); // console.log(lists)

                    let newLists =
                        lists &&
                        lists.filter((item) => {
                            return item.authStatus == 1;
                        });
                    console.log(newLists);
                    this.setData({
                        banner: lists,
                        parkingSpace: res.data.length ? res.data[this.currentbanner].parkingNumber : ''
                    });
					this.$forceUpdate()
                    this.getmyCarOrderLog(); // console.log(res.data[0].parkingNumber, "aasa");
                }
            });
        },

        //tab切换
        onChange(e) {
            this.setData({
                active: e.detail.index
            });
            this.getmyCarOrderLog();
        },

        //上下架
        handlechangeSaleStatus(e, _dataset) {
            /* ---处理dataset begin--- */
            // this.datasetHandle(e, _dataset);
            /* ---处理dataset end--- */
            console.log(e,_dataset);

            if (_dataset.value.saleStatus === 0) {
                this.setData({
                    saleStatus: 1
                });
                Dialog.confirm({
                    message: '是否确定上架？'
                })
                    .then(() => {
                        this.getchangeSaleStatus(_dataset.value); // this.getmySpaceList();
                    })
                    .catch(() => {
                        // on cancel
                    });
            } else {
                this.setData({
                    saleStatus: 0
                });
                Dialog.confirm({
                    message: '是否确定下架？'
                })
                    .then(() => {
                        this.getchangeSaleStatus(_dataset.value); // this.getmySpaceList(); //移到上面的请求中
                    })
                    .catch(() => {
                        // on cancel
                    });
            }
        },

        //编辑
        handleedit(e) {
            let type = e.currentTarget.dataset.value.plmParkingSpaceManage;
            let saleStatus = e.currentTarget.dataset.value.saleStatus;

            if (saleStatus == 1) {
                //上架状态，1已上架，0下架
                uni.showToast({
                    title: '请将车位下架后再进行编辑！',
                    icon: 'none'
                });
                return;
            }

            if (type) {
                //已有订单 0临停  1包月
                var param = e.currentTarget.dataset.value.id;
                console.log(param);
                let curServiceType = type.isTemp == 1 ? 0 : type.monthType != 0 ? 1 : 0; // 0临停  1包月

                uni.navigateTo({
                    url: '../setParking2/index?id=' + param + '&active=' + curServiceType
                }); // wx.navigateTo({
                //   url: "../setParking1/index?id=" + param + "&active=" + curServiceType
                // });
            } else {
                const value = 2; //新

                var param = e.currentTarget.dataset.value.id;
                uni.navigateTo({
                    url: '../setParking2/index?id=' + param + '&active=' + value
                });
            }
        },

        //上下架接口
        getchangeSaleStatus(item) {
            const unionId = uni.getStorageSync('unionId') || '';
            const param = {
                userUnionId: unionId,
                spaceNo: item.parkingNumber,
                parkingCode: item.parkingCode,
                saleStatus: this.saleStatus
            };
            util.request(api.changeSaleStatus, param, 'POST')
                .then((res) => {
                    if (res.code == 0) {
                        uni.showToast({
                            title: res.data,
                            icon: 'none'
                        });
                        this.getmySpaceList();
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
					
                })
                .catch((err) => {
                    uni.showToast({
                        title: '请求异常，请重试',
                        icon: 'none'
                    });
                });
        },

        //我的订单列表查询（车主|车位主）
        getmyCarOrderLog() {
            const unionId = uni.getStorageSync('unionId') || '';
            const param = {
                userUnionId: unionId,
                personType: this.personType,
                orderType: this.active == 0 ? 1 : 2,
                pageNo: 1,
                pageSize: 100,
                parkingSpace: this.parkingSpace //车位号，人员类型是车位主的时候必传
            };
            util.request(api.myCarOrderLog, param, 'POST').then((res) => {
                if (res.code == 0) {
                    if (res.data && res.data.length > 0) {
                        res.data.forEach((e) => {
                            if (e.orderStatus == 1) {
                                e.typeStatus = '预约中';
                            } else if (e.orderStatus == 2) {
                                e.typeStatus = '使用中';
                            } else if (e.orderStatus == 3) {
                                e.typeStatus = '已取消';
                            } else if (e.orderStatus == 4) {
                                e.typeStatus = '待支付';
                            } else if (e.orderStatus == 5) {
                                e.typeStatus = '支付中';
                            } else if (e.orderStatus == 6) {
                                e.typeStatus = '支付失败待重新支付';
                            } else if (e.orderStatus == 7) {
                                e.typeStatus = '支付成功';
                            } else if (e.orderStatus == 101) {
                                e.typeStatus = '待支付';
                            } else if (e.orderStatus == 102) {
                                e.typeStatus = '支付中';
                            } else if (e.orderStatus == 103) {
                                e.typeStatus = '支付失败待重新支付';
                            } else if (e.orderStatus == 104) {
                                e.typeStatus = '订单关闭';
                            } else if (e.orderStatus == 105) {
                                e.typeStatus = '支付成功';
                            } else if (e.orderStatus == 106) {
                                e.typeStatus = '预约中';
                            } else if (e.orderStatus == 107) {
                                e.typeStatus = '已完成';
                            } else if (e.orderStatus == 108) {
                                e.typeStatus = '申请退租中';
                            } else if (e.orderStatus == 109) {
                                e.typeStatus = '车位主申请退租中';
                            } else if (e.orderStatus == 110) {
                                e.typeStatus = '已退租';
                            }

                            if (e.durationUnit == 1) {
                                e.dw = '年';
                            } else if (e.durationUnit == 2) {
                                e.dw = '个月';
                            } else if (e.durationUnit == 3) {
                                e.dw = '日';
                            } else if (e.durationUnit == 4) {
                                e.dw = '小时';
                            } else if (e.durationUnit == 5) {
                                e.dw = '分钟';
                            }
                        });
                    }

                    this.setData({
                        list: res.data
                    });
                }
            }); // /***新的查询接口 */
            // let param = {
            // }
            // util.request(api.orderOverview,param,'GET').then(res=>{
            //   if(res.success){
            //     this.setData({
            //             list: res.data
            //     });
            //   }else{
            //     wx.showToast({
            //       title: res.msg || '接口出错了',
            //       icon:'none'
            //     })
            //   }
            // })
            // .catch(err=>{
            //   wx.showToast({
            //     title: '接口出错了',
            //     icon:'none'
            //   })
            // })
        }
    }
};
</script>
<style>
@import './index.css';
</style>
